import * as actionTypes from './constants';

const defaultstate = {
  maindata: [],
  index: 0, // tabbar 哪个被激活？ 核心状态
  selectGoods: []
}

const reducer = (state = defaultstate, action) => {
  switch (action.type) {
    case actionTypes.SET_INDEX:
      return {
        ...state, index: action.data
      }
    case actionTypes.CHANGE_MAINDATA:
      return {
        ...state, maindata: action.data
      }
    // case actionTypes.CHANGE_SELECTGOODS:
    // 			// 深拷贝 先转成json字符串，再转成对象
    // 	return {
    // 		...state, selectGoods: JSON.parse(JSON.stringify([...state.selectGoods, action.data]))
    // 		}
    default:
      return state;
  }
}

export default reducer;
